﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AfterlifeLib.GameScreens;
using Microsoft.Xna.Framework.Media;
using AfterlifeLib.GameScreens.Menus;

namespace Afterlife.Screens
{
    public class MainOptionsScreen : MenuScreen
    {
        public MainOptionsScreen(bool isPopup)
            : base("Options")
        {
            IsPopup = isPopup;

            MenuEntry backMenuEntry = new MenuEntry("Back");
            SliderMenuEntry musicVolumeMenuEntry = new SliderMenuEntry("Music Volume", 0.0f, 1.0f, GameOptions.MusicVolume);
            SliderMenuEntry soundEffectsVolumeMenuEntry = new SliderMenuEntry("Sound Effects Volume", 0.0f, 1.0f, GameOptions.SoundEffectsVolume);
            BooleanMenuEntry testBooleanMenuEntry = new BooleanMenuEntry("Boolean Test", false);
            ListMenuEntry testListMenuEntry = new ListMenuEntry("List Test", new string[] { "Test1", "Test2", "Test3", "Test4", "Test5" });

            backMenuEntry.Selected += BackMenuEntrySelected;
            musicVolumeMenuEntry.ValueChanged += MusicVolumeMenuEntryValueChanged;
            soundEffectsVolumeMenuEntry.ValueChanged += SoundEffectsVolumeMenuEntryValueChanged;

            MenuEntries.Add(backMenuEntry);
            MenuEntries.Add(musicVolumeMenuEntry);
            MenuEntries.Add(soundEffectsVolumeMenuEntry);
            MenuEntries.Add(testBooleanMenuEntry);
            MenuEntries.Add(testListMenuEntry);
        }

        void BackMenuEntrySelected(object sender, EventArgs e)
        {
            ExitScreen();
        }

        void MusicVolumeMenuEntryValueChanged(object sender, ValueChangedEventArgs e)
        {
            GameOptions.MusicVolume = e.Value;
            MediaPlayer.Volume = e.Value;
        }

        void SoundEffectsVolumeMenuEntryValueChanged(object sender, ValueChangedEventArgs e)
        {
            GameOptions.SoundEffectsVolume = e.Value;
        }
    }
}
